//
// Created by rebeater on 2020/10/9.
//
/* 2021/1/1 增加了ImuData_Raw 结构体，以最小体积保存保存原始数据
 *
 *
 *
 * */
#ifndef TIMER_DEMO_NAV_STRUCT_H
#define TIMER_DEMO_NAV_STRUCT_H

#include <iostream>
//#include <main.h>

#ifdef __cplusplus
extern "C" {
#endif
#define _PI 3.1415926535897932
#define _hour 3600
#define _min 60
#define _sqrt_h 60
#define _deg (_PI/180.0)
#define _mGal (1e-5)
#define _ppm (1e-6)
typedef double NavTime;
//typedef long unsigned int uint32_t;
//typedef unsigned short uint8_t;

typedef struct {
    double gpst;
    double lat;
    double lon;
    double h;
    double n_std;
    double e_std;
    double d_std;
    double h_dop;/* H DOP */
    double v_dop;/* V DOP */
    int mode;/* same as GNGGA */
    int ns;/* number of satellites */
} GnssData;

typedef struct {
    double gpst;
    double gyro[3];
    double acce[3];
} ImuData;
typedef struct {
    uint32_t gpst;
    int16_t gyro[3];
    int16_t acce[3];
} ImuData_Raw;/*8byte*/

/*4+4+8+8*3+8*3=64*/
typedef struct {
    double gpst;
    double lat;
    double lon;
    double h;
    double vn;
    double ve;
    double vd;
    double roll;
    double pitch;
    double yaw;
    double ab[3];
    double gb[3];
/*    double pos_std_[3];
    double vel_std_[3];
    double atti_std_[3];*/
    long mode;
} NavEpoch;
/**
 * 辅助数据
 */
typedef struct {
    double gpst;
    double pressure_pa; /* 气压计 pa */
    double temperature_c;/*摄氏度 deg C*/
    double velocity;/* 速度 里程计数据*/
} AuxiliaryData;


typedef struct {
    uint32_t header;
    uint32_t reserved;
    NavEpoch navEpoch;
    ImuData imuData;
    GnssData gnssData;
    AuxiliaryData auxiliaryData;
} OutputData;

typedef enum {
    GNSS_OK = 0,
    GNSS_CHECK_FAILED = 1,/* 校验位错误*/
    GNSS_NOT_NMEA_MESSAGE = 2,/* 非NMEA消息*/
    GNSS_NOT_SUPPORTED_MESSAGE = 3, /* 非目标NMEA消息*/
} GnssErrorCode;

typedef enum {
    UseGiven = 0,
    Moving = 1,
    Static = 2
} AlignMode;
typedef enum {
    GNSS_TXT_POS_7 = 0,/*7行那种*/
    GNSS_BIN_POS_7 = 1,/*7行那种*/
    GNSS_TXT_POS_14 = 2,/*14行那种*/
    GNSS_BIN_POS_14 = 3,/*14行那种*/
    RTKLIB_TXT_POS = 4,
    GNSS_TXT_POS_VEL = 5,
    RESERVED = 6,
} GnssFormat;
typedef enum {
    UNVALID = -1,
    INITIAL = 0,
    SPP = 1,
    RTK_DGPS = 2,
    UNKNOWN_PPS = 3,
    RTK_FIX = 4,
    RTK_FLOAT = 5,
} GnssMode;
typedef enum {
    SYS_STA_ERROR = 0,
    SYS_STA_SPP = 1,
    SYS_STA_DGPS = 2,
    SYS_STA_FIX = 3,
    SYS_STA_FLOAT = 4,
    SYS_STA_INS = 5,
} SystemState;
typedef struct {
    double arw;
    double vrw;
    double ab_ini[3];
    double gb_ini[3];
    double as_ini[3];
    double gs_ini[3];
    double ab_std;
    double gb_std;
    double gs_std;
    double as_std;
    double at_corr;
    double gt_corr;
} ImuPara;

typedef enum {
    ASCII = 1,
    BINARY = 2,
    NONE = 0
} OutputMode;
/**
 *
 */
typedef enum {
    WORK_RT_CAR = 0,/*实时车载模式*/
    WORK_RT_PDR = 1,/*实时PDR模式*/
    WORK_DARA_COLLECT = 2,/*数据采集模式*/
} WorkMode;
typedef struct {

#ifdef STM32H743xx
    WorkMode work_mode;
    OutputMode output_mode;
#else
    /*后处理时用到*/
    std::string imu_filepath;
    std::string gnss_filepath;
    std::string imu_parameter_cfg_path;
    std::string output_filepath;
    NavTime start_time{0};
    NavTime end_time{0};
    GnssFormat gnss_fmt = GNSS_TXT_POS_14;
#endif
    ImuPara imuPara;
    int imu_data_rate;
    AlignMode align_mode;
    NavEpoch init_epoch;
    int nhc_enable;
    float nhc_var;
    int zupt_enable;
    float zupt_var;
    float zupta_var;
    float antenna_arm[3];
    int odo_enable;
    float odo_var;
    float odo_wheel_radius;

} Option;


typedef enum {
    LED_OFF = 0,
    LED_RED = 1,
    LED_GREEN = 2,
    LED_YELLOW = 3,
    LED_BLUE = 4,
    LED_PINK = 5,
    LED_CYAN = 6,
    LED_WHITE = 7
} LED_COLOR;


#ifdef __cplusplus
}
#endif


#endif //TIMER_DEMO_NAV_STRUCT_H
